package com.hw.one.peach.core.controller;

import com.hw.one.core.controller.BaseController;
import com.hw.one.core.result.MsgResult;
import com.hw.one.dam2.common.SiteTypeEnum;
import com.hw.one.peach.core.service.IRaiseDustDataService;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/14.
 */
@RestController
@RequestMapping(path = "raiseDustData")
public class RaiseDustDataController extends BaseController{

    @Resource
    private IRaiseDustDataService raiseDustDataService;

    /**
     * 实时监测 市建委扬尘数据
     * @return
     */
    @RequestMapping(value = "/findRaiseDustRealData", method = RequestMethod.GET)
    public MsgResult findRaiseDustRealData(HttpServletRequest request) {
        try {
            Map<String, Object> paramMap = wrapParams(request);
            String siteType = (String) paramMap.get("siteType");
            paramMap.put("siteType", StringUtils.isEmpty(siteType) ? SiteTypeEnum.RAISE_DUST_NEW_SITE.getValue() : siteType);
            Object obj = raiseDustDataService.findRaiseDataRealData(paramMap);
            return MsgResult.okResult(obj);

        }catch (Exception e) {
            log.error("市建委扬尘数据", e);
            return MsgResult.exceptionResult();
        }
    }
}
